##
# client.py - Created by Timothy Morey on 6/10/2012
#
# This file provides a ctypes wrapper for libnvn items defined in client.h.
#

import ctypes

from libnvn import nvn

class Client(ctypes.Structure):
    _fields_ = [
                ('ServerName', ctypes.c_char * 64),
                ('Port',       ctypes.c_char * 8),
                ('Async',      ctypes.c_int),
               ]

ConnectClient = nvn.ConnectClient
ConnectClient.restype = ctypes.c_int
ConnectClient.argtypes = [
                          ctypes.c_char_p, 
                          ctypes.c_char_p, 
                          ctypes.POINTER(ctypes.POINTER(Client)),
                         ]

ConnectAsyncClient = nvn.ConnectAsyncClient
ConnectAsyncClient.restype = ctypes.c_int
ConnectAsyncClient.argtypes = [
                               ctypes.c_char_p, 
                               ctypes.c_char_p, 
                               ctypes.POINTER(ctypes.POINTER(Client)),
                              ]

DestroyClient = nvn.DestroyClient
DestroyClient.restype = ctypes.c_int
DestroyClient.argtypes = [
                          ctypes.POINTER(Client),
                         ]

PingServer = nvn.PingServer
PingServer.restype = ctypes.c_int
PingServer.argtypes = [
                       ctypes.c_char_p,
                       ctypes.c_char_p,
                      ]

Send = nvn.Send
Send.restype = ctypes.c_int
Send.argtypes = [
                 ctypes.POINTER(Client), 
                 ctypes.POINTER(ctypes.c_char), 
                 ctypes.c_int,
                ]

SendAndReceive = nvn.SendAndReceive
SendAndReceive.restype = ctypes.c_int
SendAndReceive.argtypes = [
                           ctypes.POINTER(Client), 
                           ctypes.POINTER(ctypes.c_char), 
                           ctypes.c_int, 
                           ctypes.POINTER(ctypes.c_char), 
                           ctypes.POINTER(ctypes.c_int),
                          ]
